package com.eagle.epay.config;

import org.springframework.amqp.core.Binding;
import org.springframework.amqp.core.BindingBuilder;
import org.springframework.amqp.core.FanoutExchange;
import org.springframework.amqp.core.Queue;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.core.env.Environment;


@Configuration
public class FanoutRabbitConfig {

	@Autowired
	private Environment env;

    @Bean(name = "payNotifyQueue")
    public Queue payNotifyQueue() {
        return new Queue(env.getProperty("epay.rabbitmq.fanout.queue.paynotify.name"));
    }

    @Bean
	FanoutExchange fanoutExchange() {
        return new FanoutExchange(env.getProperty("epay.rabbitmq.fanout.exchange.name"));
    }

    @Bean
	Binding bindingExchange(Queue payNotifyQueue, FanoutExchange fanoutExchange) {
        return BindingBuilder.bind(payNotifyQueue).to(fanoutExchange);
    }







}
